package com.g2.rpc.rpc.balance;

import com.g2.rpc.rpc.Invoker;
import com.g2.rpc.rpc.LoadBalance;

import java.net.URI;
import java.util.Map;
import java.util.Random;

/**
 * 描述:
 * ${DESCRIPTION}
 *
 * @author lingjiu.kong
 * @version 1.0
 * @date 2021-03-09 23:25
 */
public class RandomLoadBalance implements LoadBalance {
    @Override
    public Invoker select(Map<URI, Invoker> maps) {
        int index = new Random().nextInt(maps.values().size());
        return maps.values().toArray(new Invoker[]{})[index];
    }
}
